import { Field, InputType, Int, ObjectType, PartialType } from '@nestjs/graphql';
import { GraphQLBigInt } from 'graphql-scalars';
import { BaseCreateSchema, PageInput, PaginatedResponse, SearchInput } from 'src/common/mongodb/commonSchema';
import { Role } from '../entities/role.entity';
import { MongoQueryScalar } from 'src/common/scalars/mongo.query.scalar';

@InputType()
export class CreateRoleInput extends BaseCreateSchema {
  @Field(() => String, { description: '角色名' })
  name: string;

  @Field(() => [GraphQLBigInt], { description: '权限列表' })
  powers: number[];

  @Field(() => String, { nullable: true, description: 'code' })
  code: string;

  @Field(() => String, { nullable: true, description: '描述' })
  description: string;
}

@InputType()
export class UpdateRoleInput extends PartialType(CreateRoleInput) {
  @Field(() => Int)
  _id: number;
}


@InputType()
export class SearchRoleInput {
  @Field(() => GraphQLBigInt, { nullable: true }) _id: number;

  @Field(() => MongoQueryScalar, { nullable: true }) name: string;
}
/** 搜索输入&排序输入 */
@InputType()
export class SearchRoleSortInput extends SearchInput<SearchRoleInput>(SearchRoleInput) {
}

@InputType()
export class PageRoleInput extends PageInput<SearchRoleInput>(SearchRoleInput) {
}

@ObjectType()
export class PageRoleResponse extends PaginatedResponse<Role>(Role) {
}
